package com.xiyuan.smartutils.template.engine.exception;

import com.xiyuan.smartutils.Validates;

/**
 * 定义语句解析异常，可以得到出错的路径、行列号
 * 
 * @author lgz 2020年10月15日 新建与整理
 */
public class StatementException extends RuntimeException
{
    private static final long serialVersionUID = 1L;
    protected String path;
    protected int line;
    protected int column;
    
    public StatementException(String message)
    {
        this(message, null);
    }
    
    public StatementException(String message, Throwable e)
    {
        super(message, e);
    }
    
    public StatementException(int line, int column, String message)
    {
        this(null, line, column, message);
    }
    
    public StatementException(String path, int line, int column, String message)
    {
        this(path, line, column, message, null);
    }
    
    public StatementException(String path, int line, int column, String message, Throwable exception)
    {
        this(new StringBuilder("[").append(Validates.isBlank(path) ? "自定义表达式" : path).append("]").append("[第").append(line).append("行][第").append(column).append("列][").append(message)
            .append("]").toString(), exception);
        
        this.path = path;
        this.line = line;
        this.column = column;
    }
}
